home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / WASTE 1.0a4 Distribution / Interfaces 2 / Components.p next >
Text File  |  1993-07-28  |  9KB  |  283 lines

  1. unit Components;
  2.  
  3. { Pascal Interface to the Macintosh Libraries }
  4.  
  5. { Copyright © 1990-1993 Apple Computer, Inc. }
  6.  
  7. { This file has been processed by the THINK Pascal Source Converter, v. 1.1.2 }
  8. { and further adapted for use in conjunction with THINK Pascal }
  9.  
  10. interface
  11.  
  12.     const
  13.         gestaltComponentMgr = 'cpnt';
  14.  
  15.         kAnyComponentType = 0;
  16.         kAnyComponentSubType = 0;
  17.         kAnyComponentManufacturer = 0;
  18.         kAnyComponentFlagsMask = 0;
  19.  
  20.         cmpWantsRegisterMessage = $80000000;
  21.  
  22. { Component Resource Extension flags }
  23.         componentDoAutoVersion = 1;
  24.         componentWantsUnregister = 2;
  25.         componentAutoVersionIncludeFlags = 4;
  26.  
  27.     type
  28.         ComponentDescription = record
  29.                 componentType: OSType;                                { A unique 4-byte code indentifying the command set }
  30.                 componentSubType: OSType;                            { Particular flavor of this instance }
  31.                 componentManufacturer: OSType;                        { Vendor indentification }
  32.                 componentFlags: LONGINT;                            { 8 each for Component,Type,SubType,Manuf/revision }
  33.                 componentFlagsMask: LONGINT;                        { Mask for specifying which flags to consider in search, zero during registration }
  34.             end;
  35.  
  36.         ResourceSpec = record
  37.                 resType: OSType;                                    { 4-byte code  }
  38.                 resId: INTEGER;                                    {    }
  39.             end;
  40.  
  41.         ComponentResourcePtr = ^ComponentResource;
  42.         ComponentResourceHandle = ^ComponentResourcePtr;
  43.         ComponentResource = record
  44.                 cd: ComponentDescription;                            { Registration parameters }
  45.                 component: ResourceSpec;                            { resource where Component code is found }
  46.                 componentName: ResourceSpec;                        { name string resource }
  47.                 componentInfo: ResourceSpec;                        { info string resource }
  48.                 componentIcon: ResourceSpec;                        { icon resource }
  49.             end;
  50.  
  51.         ComponentResourceExtension = record
  52.                 componentVersion: LONGINT;            { version of Component }
  53.                 componentRegisterFlags: LONGINT;            { flags for registration }
  54.                 componentIconSuite: INTEGER;            { resource id of Icon Suite }
  55.             end;
  56.  
  57.         Component = ^ComponentRecord;
  58.         ComponentRecord = record
  59.                 data: array[0..0] of LONGINT;
  60.             end;
  61.  
  62.         ComponentInstance = ^ComponentInstanceRecord;
  63.         ComponentInstanceRecord = record
  64.                 data: array[0..0] of LONGINT;
  65.             end;
  66.  
  67. { Structure received by Component:  }
  68.         ComponentParameters = packed record
  69.                 flags: CHAR;                                        { call modifiers: sync/async, deferred, immed, etc }
  70.                 paramSize: CHAR;                                    { size in bytes of actual parameters passed to this call }
  71.                 what: INTEGER;                                        { routine selector, negative for Component management calls }
  72.                 params: array[0..0] of LONGINT;                    { actual parameters for the indicated routine }
  73.             end;
  74.  
  75.         ComponentResult = LONGINT;
  76.  
  77.         ComponentRoutine = ProcPtr;
  78.  
  79.         ComponentFunction = ProcPtr;
  80.  
  81.  
  82. {******************************************************}
  83. {* Required Component routines}
  84. {******************************************************}
  85.  
  86.     const
  87.         kComponentOpenSelect = -1;                            { ComponentInstance for this open }
  88.         kComponentCloseSelect = -2;                            { ComponentInstance for this close }
  89.         kComponentCanDoSelect = -3;                            { selector # being queried }
  90.         kComponentVersionSelect = -4;                        { no params }
  91.         kComponentRegisterSelect = -5;                        { no params }
  92.         kComponentTargetSelect = -6;                        { ComponentInstance for top of call chain }
  93.         kComponentUnregisterSelect = -7;                    { no params }
  94.  
  95. { Set Default Component flags }
  96.         defaultComponentIdentical = 0;
  97.         defaultComponentAnyFlags = 1;
  98.         defaultComponentAnyManufacturer = 2;
  99.         defaultComponentAnySubType = 4;
  100.         defaultComponentAnyFlagsAnyManufacturer = defaultComponentAnyFlags + defaultComponentAnyManufacturer;
  101.         defaultComponentAnyFlagsAnyManufacturerAnySubType = defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType;
  102.  
  103. { errors from component manager & components }
  104.         invalidComponentID = -3000;
  105.         validInstancesExist = -3001;
  106.         componentNotCaptured = -3002;
  107.         componentDontRegister = -3003;
  108.  
  109.         badComponentInstance = $80008001;
  110.         badComponentSelector = $80008002;
  111.  
  112.  
  113. { *******************************************************}
  114. {*                                                     *}
  115. {*              APPLICATION LEVEL CALLS                *}
  116. {*                                                     *}
  117. {*******************************************************}
  118. {* Component Database Add, Delete, and Query Routines }
  119. {*******************************************************}
  120. {}
  121.     function RegisterComponent (cd: ComponentDescription;
  122.                                     componentEntryPoint: ComponentRoutine;
  123.                                     global: INTEGER;
  124.                                     componentName: Handle;
  125.                                     componentInfo: Handle;
  126.                                     componentIcon: Handle): Component;
  127.     inline
  128.         $7001, $A82A;
  129.     function RegisterComponentResource (tr: ComponentResourceHandle;
  130.                                     global: INTEGER): Component;
  131.     inline
  132.         $7012, $A82A;
  133.     function UnregisterComponent (aComponent: Component): OSErr;
  134.     inline
  135.         $7002, $A82A;
  136.  
  137.     function FindNextComponent (aComponent: Component;
  138.                                     looking: ComponentDescription): Component;
  139.     inline
  140.         $7004, $A82A;
  141.     function CountComponents (looking: ComponentDescription): LONGINT;
  142.     inline
  143.         $7003, $A82A;
  144.  
  145.     function GetComponentInfo (aComponent: Component;
  146.                                     var cd: ComponentDescription;
  147.                                     componentName: Handle;
  148.                                     componentInfo: Handle;
  149.                                     componentIcon: Handle): OSErr;
  150.     inline
  151.         $7005, $A82A;
  152.     function GetComponentListModSeed: LONGINT;
  153.     inline
  154.         $7006, $A82A;
  155.  
  156.  
  157. { *******************************************************}
  158. {* Component Instance Allocation and dispatch routines }
  159. {*******************************************************}
  160. {}
  161.     function OpenComponent (aComponent: Component): ComponentInstance;
  162.     inline
  163.         $7007, $A82A;
  164.     function CloseComponent (aComponentInstance: ComponentInstance): OSErr;
  165.     inline
  166.         $7008, $A82A;
  167.  
  168.     function GetComponentInstanceError (aComponentInstance: ComponentInstance): OSErr;
  169.     inline
  170.         $700A, $A82A;
  171.  
  172.  
  173. {  direct calls to the Components  }
  174.     function ComponentFunctionImplemented (ci: ComponentInstance;
  175.                                     ftnNumber: INTEGER): LONGINT;
  176.     inline
  177.         $2F3C, $2, $FFFD, $7000, $A82A;
  178.     function GetComponentVersion (ci: ComponentInstance): LONGINT;
  179.     inline
  180.         $2F3C, $0, $FFFC, $7000, $A82A;
  181.     function ComponentSetTarget (ci: ComponentInstance;
  182.                                     target: ComponentInstance): LONGINT;
  183.     inline
  184.         $2F3C, $4, $FFFA, $7000, $A82A;
  185.  
  186.  
  187. {****************************************************}
  188. {*                                                    *}
  189. {*               CALLS MADE BY Components             *}
  190. {*                                                    *}
  191. {******************************************************}
  192.  
  193.  
  194. { *******************************************************}
  195. {* Component Management routines}
  196. {*******************************************************}
  197. {}
  198.     procedure SetComponentInstanceError (aComponentInstance: ComponentInstance;
  199.                                     theError: OSErr);
  200.     inline
  201.         $700B, $A82A;
  202.  
  203.     function GetComponentRefcon (aComponent: Component): LONGINT;
  204.     inline
  205.         $7010, $A82A;
  206.     procedure SetComponentRefcon (aComponent: Component;
  207.                                     theRefcon: LONGINT);
  208.     inline
  209.         $7011, $A82A;
  210.  
  211.     function OpenComponentResFile (aComponent: Component): INTEGER;
  212.     inline
  213.         $7015, $A82A;
  214.     function CloseComponentResFile (refnum: INTEGER): OSErr;
  215.     inline
  216.         $7018, $A82A;
  217.  
  218.  
  219. { *******************************************************}
  220. {* Component Instance Management routines}
  221. {*******************************************************}
  222. {}
  223.     function GetComponentInstanceStorage (aComponentInstance: ComponentInstance): Handle;
  224.     inline
  225.         $700C, $A82A;
  226.     procedure SetComponentInstanceStorage (aComponentInstance: ComponentInstance;
  227.                                     theStorage: Handle);
  228.     inline
  229.         $700D, $A82A;
  230.  
  231.     function GetComponentInstanceA5 (aComponentInstance: ComponentInstance): LONGINT;
  232.     inline
  233.         $700E, $A82A;
  234.     procedure SetComponentInstanceA5 (aComponentInstance: ComponentInstance;
  235.                                     theA5: LONGINT);
  236.     inline
  237.         $700F, $A82A;
  238.  
  239.     function CountComponentInstances (aComponent: Component): LONGINT;
  240.     inline
  241.         $7013, $A82A;
  242.  
  243. {  useful helper routines for convenient method dispatching  }
  244.     function CallComponentFunction (params: ComponentParameters;
  245.                                     func: ComponentFunction): LONGINT;
  246.     inline
  247.         $70FF, $A82A;
  248.     function CallComponentFunctionWithStorage (storage: Handle;
  249.                                     params: ComponentParameters;
  250.                                     func: ComponentFunction): LONGINT;
  251.     inline
  252.         $70FF, $A82A;
  253.     function DelegateComponentCall (originalParams: ComponentParameters;
  254.                                     ci: ComponentInstance): LONGINT;
  255.     inline
  256.         $7024, $A82A;
  257.  
  258.     function SetDefaultComponent (aComponent: Component;
  259.                                     flags: INTEGER): OSErr;
  260.     inline
  261.         $701E, $A82A;
  262.     function OpenDefaultComponent (componentType: OSType;
  263.                                     componentSubType: OSType): ComponentInstance;
  264.     inline
  265.         $7021, $A82A;
  266.     function CaptureComponent (capturedComponent: Component;
  267.                                     capturingComponent: Component): Component;
  268.     inline
  269.         $701C, $A82A;
  270.     function UncaptureComponent (aComponent: Component): OSErr;
  271.     inline
  272.         $701D, $A82A;
  273.     function RegisterComponentResourceFile (resRefNum: INTEGER;
  274.                                     global: INTEGER): LONGINT;
  275.     inline
  276.         $7014, $A82A;
  277.     function GetComponentIconSuite (aComponent: Component;
  278.                                     var iconSuite: Handle): OSErr;
  279.     inline
  280.         $702A, $A82A;
  281.  
  282. implementation
  283. end.